Sub test()
    Dim cn As New ADODB.Connection
    
    Dim tdata As Table
    Dim sql(50) As String
    
    Set tdata = ActiveDocument.Tables(1)
    
    Dim cnStr As String
    
    'database
    cnStr = "Provider = MSDAORA.1;Password=" & "lisro" & _
                     ";User ID=" & "lisro" & ";Data Source=" & "fanying" & ";Persist Security Info=True"
    
    cn.Open cnStr
    
    'MsgBox ActiveDocument.Tables(1).Cell(4, 3).Range.Text
    n = 1
    
    For i = 1 To 50
        If Mid(Trim(tdata.Cell(i, 3).Range.Text), 1, 6) = "select" Then
            
            MsgBox n
            
            sql(n) = (Mid(ActiveDocument.Tables(1).Cell(i, 3).Range.Text, 1, _
                Len(ActiveDocument.Tables(1).Cell(i, 3).Range.Text) - 2))
            n = n + 1
            
        End If
    Next i
    
    MsgBox sql(1)
    
'    If (Mid(ActiveDocument.Tables(1).Cell(4, 3).Range.Text, 1, _
'        Len(ActiveDocument.Tables(1).Cell(4, 3).Range.Text) - 2)) = Chr(13) Then
'            MsgBox "enter button detected"
'    End If


End Sub
